<script>
	//导入接口请求文件
	import {
		Request
	} from './utils/request.js';
	import Config from './utils/config.js';
	export default {
		globalData: {
			//用户登陆状态
			Logincode: '',
			//用户openid
			openid: '',
			//用户id
			userid: '',
			//
			state: '',
			//
			code: '',
			host: '',
			// 
			houseList: '',
			//版本参数：development 开发版本，online 上线版本
			DevelopVersion: 'online',
			//项目名：使用上线版本是需传入->项目名参数：renthouse 使用开发版本传入->项目名参数：huali
			project: 'renthouse',
			// 租客上线版本的小程序版本的appid：wx96570dd0829f1548
			// 测试板appid：wx1a26121e88e594bc
			
			//此参数为首页筛选 的变量名
			select_city: '',
			select_hotid: '' ,
			select_district: '',
			select_chooseTimeId: '',
			select_startmoney: '',
			select_endmoney: '',
			select_livingId: '',
			select_bedId: '',
			select_toiletId: '',
			select_labelName: '',
		},
		onLaunch: function() {
			this.$scope.globalData.host = Config.service.host;
			var date = new Date('2021-04-01 19:43:00');
			// 有三种方式获取
			// var time1 = date.getTime();
			// var time2 = date.valueOf();
			// var time3 = Date.parse(date);
			// console.log(time1);//1398250549123
			// console.log(time2);//1398250549123
			// console.log(time3);//1398250549000
			// console.log('App Launch');
			
			//login接口拿到code给后台,拿去交换openid
			uni.login({
				success: (res) => {
					// console.log('成功',res)
					this.code = res.code
					this.$scope.globalData.code = res.code
					//获取openid,用户信息接口
					new Request('User_Login/GetUserOpendInfoAndRegister').request(
						() => {return 'POST';},
						() => {
							return {
								code: this.code,
								DevelopVersion: this.$scope.globalData.DevelopVersion,
								project: this.$scope.globalData.project,
							}
						},
						(res) => {
							this.$scope.globalData.Logincode = res.data.data.LoginCode
							this.$scope.globalData.openid = res.data.data.openid
							this.$scope.globalData.userid = res.data.data.userid
							// this.$scope.globalData.userid = 47;
							// this.$scope.globalData.openid = 'oYJnf4jSbRlcJlx26unZeuZUA_Y4';
							// this.$scope.globalData.openid = 'oYJnf4l0VQJTGS0gFayRKDoV-VHU';
							// this.$scope.globalData.userid = 45;
							// this.$scope.globalData.openid = 'oYJnf4sospOztdLzgwuCSlylzC4k';
							// this.$scope.globalData.userid = 122;
							// console.log(this.$scope.globalData.openid)
						}
					);
				},
				fail: (err) => {
					// console.log('失败')
				}
			})

		},
		onShow: function() {
			// console.log('App Show')
		},
		onHide: function() {
			// console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
